<template>
  <div class="history-wrap">
    <el-dialog  title="审批历史" :visible.sync="subVisible" @close="visibleFun"
                :close-on-click-modal="false"
                append-to-body :width="isMobile ? '95%':'56%'">
      <!--<p class="map">审批历史</p>-->
      <el-table
        :data="historyTables"
        :header-cell-style="{background: '#FAFAFA'}"
        style="width: 100%"
        v-if="!isMobile"
      >
        <el-table-column label="序号" type="index" width="60" ></el-table-column>
        <el-table-column show-overflow-tooltip prop="nodeName" label="审批环节"></el-table-column>
        <el-table-column show-overflow-tooltip prop="completeTime" label="审批时间">
          <template slot-scope="scope">
            <span>{{scope.row.completeTime | formatTime('Y-M-D')}}</span>
          </template>
        </el-table-column>
        <el-table-column show-overflow-tooltip prop="taskResult" label="审批结果"></el-table-column>
        <el-table-column show-overflow-tooltip prop="opinion" label="审批意见">
          <template slot-scope="scope">
            <span v-if="scope.row.opinion ||scope.row.opinion === 'null' " >{{scope.row.opinion}}</span>
            <span v-else>暂无</span>
          </template>
        </el-table-column>
        <el-table-column label="审批签名">
          <template slot-scope="scope">
             <span  v-if="!scope.row.signFileName">暂无</span>
            <div class="img-box" :class="!isMobile ?'pc-img-box':''" v-if="scope.row.signFileName">
            <el-image   :src='scope.row.signFileName' :preview-src-list="[scope.row.signFileName]"></el-image>
           </div>
          </template>
        </el-table-column>
        <el-table-column show-overflow-tooltip prop="userName" label="审批人"></el-table-column>
      </el-table>
      <ul v-if="isMobile">
        <li v-for="item in historyTables" :key="item.id">
          <div>审批环节：{{item.nodeName}}</div>
          <div>审批人：{{item.userName}}</div>
          <div>审批时间：{{item.completeTime | formatTime('Y-M-D')}}</div>
          <div>审结果：{{item.taskResult}}</div>
          <div>审意见：</div>
          <div v-if="item.opinion ||item.opinion === 'null'">{{item.opinion}}</div>
          <div v-else>暂无</div>
           <div>审批签名：<span v-if="!item.signFileName">暂无</span></div>
          <div class="img-box" v-if="item.signFileName">
            <el-image  :src='item.signFileName' :preview-src-list="[item.signFileName]"></el-image>
          </div>
        </li>
      </ul>
      <span slot="footer" class="dialog-footer">
        <el-button class="global-button" round type="primary" @click="$emit('update:visible',false)">关闭</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "comHistoryLook",
  props: {
    visible:{
      type: Boolean,
      default: false
    },
    historyTables:{
      type: Array,
      default: []
    },
    isMobile:{
      type:Boolean,
      default:false
    }
  },
  data() {
    return {
      historyPage: 5,
      currentPage: 1,
      subVisible:false
    }
  },
  watch:{
    visible(){
      this.subVisible = this.visible
    }

  },
  methods: {
    historyChanger (val) {
        this.currentPage = val
    },
    historySizeChanger (val) {
        this.historyPage = val
    },
    visibleFun(){
      this.$emit('closeDetailFun')
      this.$emit('update:visible',false)
    }
  }
};
</script>

<style lang='scss' scoped>

  	.img-box{
		width: 100px;
		height: 100px;
    margin-top: 10px;
		position: relative;
		overflow: hidden;
		display: inline-block;
		border-radius: 5px;
		border: 0.5px solid #f2f2f2;
      transform: rotate(-90deg);
		.el-image{
			width: 100%;
			height: 100%;
			margin: auto;
			position: absolute;
			left: 0;
			top: 0;
			right: 0;
			bottom: 0;
		}
	}
  .pc-img-box{
    	width: 100px;
		height: 80px;
  }
  ul{
    list-style-type: none;
    padding: 0;
    li{
      margin-bottom: 20px;
      div{
        margin: 5px 0;
      }
    }
  }
.history-wrap {
    .el-dialog__header {
        display: none;
    }
    .el-dialog__body {
        padding: 0px 50px;
    }
    .el-dialog__footer {
      margin-top: 20px;
      text-align: center;
    }
    .map {
        font-size: 16px;
        color: #696969;
        letter-spacing: -0.33px;
        text-align: center;
        line-height: 18px;
        padding: 45px 0px 21px;
        font-weight: 600;
    }
}
</style>
